<?php
include_once "common/basic.php";
/* 登录才能下载
if(!$func->hasLogedIn()){
	$refer = urlencode("u.php?feed=".$_GET[feedid]);
	$func->redirect2("login.php?refer=$refer");
	die();
}
*/
$id = $_GET[id];
if(!$id){
	$func->error("e12062302","文件不存在");
}
$res = $func->getResourceById($id);
if($res){
	$client_ip = $_SERVER[REMOTE_ADDR];
	if(!$func->allow_download($id,$client_ip)){
		$func->error("w12062401","下载过于频繁！");
	}
	$func->recordDownload($id,$_SESSION[uid],$client_ip);
	$func->incResourceDownload($id);
	if($res[lx]=='torrent'){
		$filepath = $func->getFilePathByFID($res[fid]);
		if(!$filepath){
			$func->error("e12062301","找不到该文件信息");
		}
		$file = $func->getFileById($res[fid]);
		$fname = "【比特圈】【bitzone.co】".$file[name];
		$func->downloadFile($filepath, $fname);
	}else{
		$func->redirect2($res[link]);
	}
}else{
	$func->error("e12061702","资源不存在");
}
die();
?>